package com.ct.service.entity;

import com.ct.entity.po.Approval;
import com.ct.entity.po.Reimbursement;
import com.ct.entity.po.Schedule;
import com.ct.entity.query.ApprovalQuery;
import com.ct.entity.query.ReimbursementQuery;
import com.ct.entity.query.ScheduleQuery;
import com.ct.mappers.ReportMapper;

/**
 * @Description:
 * @Author: cby
 * @Date: 2025/5/23 18:07
 */
public class ReportDataStrategyFactory {
    private ReportMapper<Reimbursement, ReimbursementQuery> reportReimbursementMapper;
    private ReportMapper<Approval, ApprovalQuery> reportApprovalMapper;
    private ReportMapper<Schedule, ScheduleQuery> reportScheduleMapper;

    public ReportDataStrategyFactory(ReportMapper<Reimbursement, ReimbursementQuery> reportReimbursementMapper,
            ReportMapper<Approval, ApprovalQuery> reportApprovalMapper,
            ReportMapper<Schedule, ScheduleQuery> reportScheduleMapper) {
        this.reportReimbursementMapper = reportReimbursementMapper;
        this.reportApprovalMapper = reportApprovalMapper;
        this.reportScheduleMapper = reportScheduleMapper;
    }

    public <T> ReportDataStrategy<T> createStrategy(String reportType) {
        return switch (reportType) {
            case "bar" -> (ReportDataStrategy<T>) new BarDataStrategy(reportReimbursementMapper);
            case "pie" -> (ReportDataStrategy<T>) new PieDataStrategy(reportApprovalMapper);
            case "map" -> (ReportDataStrategy<T>) new MapDataStrategy(reportScheduleMapper);
            default -> throw new IllegalArgumentException("Unsupported report type: " + reportType);
        };
    }
}
